package graph.group.zhangtao.guider.homepage.fragments;



import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.ListFragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import graph.group.zhangtao.guider.R;
import graph.group.zhangtao.guider.homepage.activities.ToolBarX;
import graph.group.zhangtao.guider.homepage.adapters.SearchItemAdapter;
import graph.group.zhangtao.guider.homepage.content.SearchItem;

/**
 * Created by T5 on 2016/6/16.
 */
public class SelectionFragment extends ListFragment {
    private Toolbar toolbar;
    private ToolBarX mToolbar;
    FragmentActivity activity;
    private List<SearchItem> searchItemList = new ArrayList<>();
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fg_selection, container, false);
        activity = getActivity();
        initToolbar();

        if (searchItemList.size()<5){
            initList();
        }

        SearchItemAdapter adapter = new SearchItemAdapter(getContext(),R.layout.search_item,R.id.tv_search_title, searchItemList);
        setListAdapter(adapter);

        return view;
    }


    private void initToolbar(){
        toolbar = (Toolbar) activity.findViewById(R.id.toolbar);
        toolbar.setVisibility(View.GONE);
        mToolbar = new ToolBarX(toolbar, (AppCompatActivity) activity);
    }


    //初始化推荐路线的列表
    private void initList(){

        SearchItem root1 = new SearchItem(getString(R.string.root_title1),
                getString(R.string.encourage_time1),
                getString(R.string.root_desc_1),
                R.mipmap.ic_launcher);
        searchItemList.add(root1);

        SearchItem root2 = new SearchItem(getString(R.string.root_title1),
                getString(R.string.encourage_time1),
                getString(R.string.root_desc_1),
                R.mipmap.ic_launcher);
        searchItemList.add(root2);

        SearchItem root3 = new SearchItem(getString(R.string.root_title1),
                getString(R.string.encourage_time1),
                getString(R.string.root_desc_1),
                R.mipmap.ic_launcher);
        searchItemList.add(root3);

        searchItemList.add(root3);
        searchItemList.add(root3);




    }


}
